import request from "../utils/request";
import { AccountType, JoinType, UserInfoType } from "../types/user";
//登录
export const userLogin = (account: AccountType) => {
  return request.post("login", account);
};
//更新用户信息
export const userUpdate = (
  userid: string,
  token: string,
  info: Pick<UserInfoType, "name" | "job" | "resume">
) => {
  return request.put(`users/${userid}`, info, {
    headers: {
      "X-LC-Session": token, //单独给当前的更新接口，追加一个新的headers配置
    },
  });
};

// 用户报名
export const joinPost = (joinObj: Omit<JoinType, "objectId">) => {
  return request.post("classes/join", joinObj);
};

// 报名状态查询
export const joinGet = (userId: string | undefined, jobId: string) => {
  return request.get("classes/join", {
    params: {
      where: {
        userId,
        jobId,
      },
    },
  });
};
